home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / socket / miami3 / miamisdk / netinclude / net / bpf.h next >
C/C++ Source or Header  |  1998-05-24  |  2KB  |  121 lines

  1. #ifndef _NET_BPF_H_
  2. #define    _NET_BPF_H_
  3.  
  4. #ifndef _SYS_TYPES_H_
  5. #include <sys/types.h>
  6. #endif
  7.  
  8. #ifndef _SYS_IOCCOM_H_
  9. #include <sys/ioccom.h>
  10. #endif
  11.  
  12. #ifndef _SYS_TIME_H_
  13. #include <sys/time.h>
  14. #endif
  15.  
  16.  
  17. #define BPF_ALIGNMENT sizeof(long)
  18. #define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
  19.  
  20. #define BPF_MAXINSNS    512
  21.  
  22. struct bpf_program {
  23.     u_int bf_len;
  24.     struct bpf_insn *bf_insns;
  25. };
  26.  
  27. struct bpf_stat {
  28.     u_int bs_recv;
  29.     u_int bs_drop;
  30. };
  31.  
  32. struct bpf_version {
  33.     u_short bv_major;
  34.     u_short bv_minor;
  35. };
  36.  
  37. #define BPF_MAJOR_VERSION    1
  38. #define BPF_MINOR_VERSION    1
  39.  
  40. #define BIOCGBLEN        _IOR('B',102,u_int)
  41. #define BIOCSBLEN        _IOWR('B',102,u_int)
  42. #define BIOCSETF        _IOW('B',103,struct bpf_program)
  43. #define BIOCFLUSH        _IO('B',104)
  44. #define BIOCGDLT        _IOR('B',106,u_int)
  45. #define BIOCGETIF        _IOR('B',107,struct ifreq)
  46. #define BIOCSETIF        _IOW('B',108,struct ifreq)
  47. #define BIOCSRTIMEOUT    _IOW('B',109,struct timeval)
  48. #define BIOCGRTIMEOUT    _IOR('B',110,struct timeval)
  49. #define BIOCGSTATS        _IOR('B',111,struct bpf_stat)
  50. #define BIOCIMMEDIATE    _IOW('B',112,u_int)
  51. #define BIOCVERSION        _IOR('B',113,struct bpf_version)
  52.  
  53. struct bpf_hdr {
  54.     struct timeval bh_tstamp;
  55.     u_long bh_caplen;
  56.     u_long bh_datalen;
  57.     u_short bh_hdrlen;
  58.     u_short bh_pad;
  59. };
  60.  
  61. #define DLT_MIAMI        100
  62.  
  63. #define BPF_CLASS(code)    ((code)&0x07)
  64. #define BPF_LD        0x00
  65. #define BPF_LDX        0x01
  66. #define BPF_ST        0x02
  67. #define BPF_STX        0x03
  68. #define BPF_ALU        0x04
  69. #define BPF_JMP        0x05
  70. #define BPF_RET        0x06
  71. #define BPF_MISC    0x07
  72.  
  73. #define BPF_SIZE(code)    ((code)&0x18)
  74. #define BPF_W        0x00
  75. #define BPF_H        0x08
  76. #define BPF_B        0x10
  77. #define BPF_MODE(code)    ((code)&0xe0)
  78. #define BPF_IMM        0x00
  79. #define BPF_ABS        0x20
  80. #define BPF_IND        0x40
  81. #define BPF_MEM        0x60
  82. #define BPF_LEN        0x80
  83. #define BPF_MSH        0xa0
  84.  
  85. #define BPF_OP(code)    ((code)&0xf0)
  86. #define BPF_ADD        0x00
  87. #define BPF_SUB        0x10
  88. #define BPF_MUL        0x20
  89. #define BPF_DIV        0x30
  90. #define BPF_OR        0x40
  91. #define BPF_AND        0x50
  92. #define BPF_LSH        0x60
  93. #define BPF_RSH        0x70
  94. #define BPF_NEG        0x80
  95. #define BPF_JA        0x00
  96. #define BPF_JEQ        0x10
  97. #define BPF_JGT        0x20
  98. #define BPF_JGE        0x30
  99. #define BPF_JSET    0x40
  100. #define BPF_SRC(code)    ((code)&0x08)
  101. #define BPF_K        0x00
  102. #define BPF_X        0x08
  103.  
  104. #define BPF_RVAL(code)    ((code)&0x18)
  105. #define BPF_A        0x10
  106.  
  107. #define BPF_MISCOP(code)    ((code)&0xf8)
  108. #define BPF_TAX        0x00
  109. #define BPF_TXA        0x80
  110.  
  111. struct bpf_insn {
  112.     u_short code;
  113.     u_char jt;
  114.     u_char jf;
  115.     long k;
  116. };
  117.  
  118. #define BPF_MEMWORDS    16
  119.  
  120. #endif
  121.